package cn.cjxy.controller;

import cn.cjxy.domain.Employee;
import cn.cjxy.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/emp")
public class EmpController {

    @Autowired
    private EmpService empService;

    /**
     * 查询所有
     * @return
     */
    @GetMapping
    public List<Employee> findAll(){
        return empService.list();
    }

    /**
     * 新增或者修改
     * @param emp
     * @return
     */
    @PostMapping
    public void save(@RequestBody Employee emp){
        empService.saveOrUpdate(emp);
    }
}
